import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { visitorRecordVO, visitorRecordForm, visitorRecordQuery } from '@/api/visitor/visitor-record/types';

/**
 * 查询访客记录列表
 * @param query
 * @returns {*}
 */

export const listvisitorRecord = (query?: visitorRecordQuery): AxiosPromise<visitorRecordVO[]> => {
  return request({
    url: '/visitor/visitor-record/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询访客记录详细
 * @param visitorRecordId
 */
export const getvisitorRecord = (visitorRecordId: string | number): AxiosPromise<visitorRecordVO> => {
  return request({
    url: '/visitor/visitor-record/' + visitorRecordId,
    method: 'get'
  });
};

/**
 * 新增访客记录
 * @param data
 */
export const addvisitorRecord = (data: visitorRecordForm) => {
  return request({
    url: '/visitor/visitor-record',
    method: 'post',
    data: data
  });
};

/**
 * 修改访客记录
 * @param data
 */
export const updatevisitorRecord = (data: visitorRecordForm) => {
  return request({
    url: '/visitor/visitor-record',
    method: 'put',
    data: data
  });
};

/**
 * 删除访客记录
 * @param visitorRecordId
 */
export const delvisitorRecord = (visitorRecordId: string | number | Array<string | number>) => {
  return request({
    url: '/visitor/visitor-record/' + visitorRecordId,
    method: 'delete'
  });
};

/**
 * 访客趋势
 * @param visitorRecordId
 */
export const getvisitorTrends = (visitorRecordId: string | number): AxiosPromise<visitorRecordVO> => {
  return request({
    url: '/visitor/visitor-record/visitorTrends' + visitorRecordId,
    method: 'get'
  });
};
